import django.contrib.admin as admin
import ourcity.news.models as models


class AttachmentAdmin(admin.ModelAdmin):
    pass
admin.site.register(models.Attachment, AttachmentAdmin)


class AttachmentInline(admin.TabularInline):
    model = models.Attachment


class NewsAdmin(admin.ModelAdmin):
    fieldsets = (
        (None, {
            'fields': (
                'type', 
                'title', 
                'subtitle', 
                'slug', 
                'author', 
                'active',
                'general_news',
            ),
        }),
        ('Post fields', {
            'fields': (
                'body',
            ),
        }),
        ('Report fields', {
            'fields': (
                'synopsis',
                'findings',
                'recommendations',
            ),
        }),
        (None, {
            'fields': (
                'issues',
                'reps',
            ),
        }),
    )
    inlines = [AttachmentInline]
    list_display = ('title', 'type', 'active', 'general_news')
    list_filter = ('type', 'active', 'general_news')
    search_fields = ('title',)
    prepopulated_fields = {'slug': ('title',)}
    raw_id_fields = ('author',)
admin.site.register(models.News, NewsAdmin)


class NewsTypeAdmin(admin.ModelAdmin):
    pass
admin.site.register(models.NewsType, NewsTypeAdmin)


#class ReportAdmin(admin.ModelAdmin):
#    # order fields in a better way
#    fields = (
#        'title', 
#        'subtitle', 
#        'slug', 
#        'author', 
#        'active',
#        'general_news',
#        'synopsis',
#        'findings',
#        'recommendations',
#        'issues',
#        'reps',
#    )
#    inlines = [AttachmentInline]
#    prepopulated_fields = {'slug': ('title',)}
#admin.site.register(models.Report, ReportAdmin)


#class PostAdmin(admin.ModelAdmin):
#    inlines = [AttachmentInline]
#    prepopulated_fields = {'slug': ('title',)}
#admin.site.register(models.Post, PostAdmin)

